<?php extract ( $_GET );

	include 'wp-includes/php/DBManager.class.php';
	
	$query = "Location: infoFilm.php?id=".$id;
	$db = new DBManager ( 'localhost', 'root', '', 'iumus' );
	
	if ( isset ( $user ) && strlen ( $user ) > 0 && $user != "noSet" ) {
		$query = "INSERT INTO  `iumus`.`watchlist` ( `idUser` , `idFilm` ) VALUES ( '".$user."',  '".$id."' )";
		$db->executeQuery ( $query );
		if ( mysql_affected_rows() < 0 )
			echo '<script type="text/javascript">alert ("You alredy added this film to your watchlist!"); location.href = "infoFilm.php?id='.$id.'";</script>';
		else echo '<script type="text/javascript">location.href = "infoFilm.php?id='.$id.'";</script>';
	} else { 
		if ( strlen ( $user ) == 0 || $user == "noSet" ) {
			echo '<script type="text/javascript">alert ("You must sign up for add this film to your watchlist!"); location.href = "infoFilm.php?id='.$id.'";</script>';
		} else echo '<script type="text/javascript">alert ("You alredy added this film to your watchlist!"); location.href = "infoFilm.php?id='.$id.'";</script>';
	}

?>